/**
 * Number formatting utilities
 */

/**
 * Format large numbers for display (e.g., 1234 -> "1.2k", 1234567 -> "1.2M", 692 -> "650+")
 * @param {number} num - Number to format
 * @returns {string} - Formatted string
 */
export function formatNumber(num) {
  if (num === null || num === undefined || isNaN(num)) {
    return '0';
  }
  
  if (num >= 1000000) {
    return (num / 1000000).toFixed(1) + 'M';
  }
  
  if (num >= 1000) {
    return (num / 1000).toFixed(1) + 'k';
  }
  
  // For numbers below 1000, round down to nearest 50 and add a plus sign
  const rounded = Math.floor(num / 50) * 50;
  return rounded.toString() + '+';
}

